<html>
<head><title>Nicofarre test</title></head>
<body style="margin: 0; cursor: none">
<script src="../tma.js"></script>
<script src="mv_common.js"></script>
<script>
tma.extlibs = [ 'ext/gl-matrix.js', 'ext/mv/MajVj.js' ];
tma.onload = function () {
  var r = 1;
  var width = 1920 / r;
  var height = 1080 / r;
  var vj = new MajVj(width, height, true);
  var nano2 = { volume: [0.0, 0.0] };
  MajVj.loadAllPlugins().then(_(function () {
    var rgb = { name: 'rgb', options: { distance: 0.002 } };
    var glow = { name: 'glow', options: { controller: nano2 } };
    var effect = { name: 'effect', options: {
        frames: [ 'wired', 'crlogo' ],
        effects: [ rgb, glow ] } };
    var stage = vj.create('frame', 'nicofarre', {
        led: MajVj.frame.nicofarre.LED_LEFT_STAGE_RIGHT,
        frames: [ effect ] });
    var emu = vj.create('effect', 'nicofarre');
    emu.setController(controller);
    var fbo = vj.screen().createFrameBuffer(width, height);
    vj.run(function (delta) {
      nano2.volume[0] = controller.nano2[0];
      nano2.volume[1] = controller.nano2[1];
      if (emulate)
        fbo.bind();
      vj.screen().setAlphaMode(false);
      vj.screen().fillColor(0.0, 0.0, 0.0, 1.0);
      stage.draw(delta);
      if (emulate) {
        vj.screen().bind();
        vj.screen().setAlphaMode(false);
        emu.draw(delta, fbo.texture);
      }
      vj.screen().flush();
    });
    window.onresize = function () {
      vj.onresize();
      emu.onresize(vj.aspect());
    };
  }), function (e) { console.error('plugin load error: ' + e.stack); });
};
</script>
</body>
</html>
